# prepare dependency
# init project
if ! [ -e init_linux_project.sh ]; then
    wget https://gitee.com/an_hongjun/EdgeCXX/raw/master/public/init_linux_project.sh && chmod +x ./init_linux_project.sh && ./init_linux_project.sh && rm ./init_linux_project.sh
fi

include_url="https://gitee.com/an_hongjun/EdgeCXX/raw/master/EdgeTimer/include"
source_url="https://gitee.com/an_hongjun/EdgeCXX/raw/master/EdgeTimer/source"
cmake_url="https://gitee.com/an_hongjun/EdgeCXX/raw/master/EdgeTimer/cmake"

include_array=(
    "edge_timer.h"
)

source_array=(
    "edge_timer.cpp"
)

cmake_array=(
    "EdgeTimer.cmake"
)

# download .h files
if [ -e include ]; then
    echo "include dir already exists."
else
    mkdir include
fi
for h_file in "${include_array[@]}"
do
    echo "download file ${h_file}"
    wget -O "include/${h_file}" "${include_url}/${h_file}"
done

# download .cpp files
if [ -e source ]; then
    echo "source dir already exists."
else
    mkdir source
fi
for cpp_file in "${source_array[@]}"
do
    echo "download file ${cpp_file}"
    wget -O "source/${cpp_file}" "${source_url}/${cpp_file}"
done

# download .cmake files
if [ -e cmake ]; then
    echo "cmake dir already exists."
else
    mkdir cmake
fi
for cmake_file in "${cmake_array[@]}"
do
    echo "download file ${cmake_file}"
    wget -O "cmake/${cmake_file}" "${cmake_url}/${cmake_file}"
done